package gsw.demo.router.toolrouter;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import gsw.demo.router.R;
import gsw.tool.router.annotation.Extra;
import gsw.tool.router.annotation.Route;
import gsw.tool.router.core.ToolRouter;

@Route(path = "/demo1/activityToolRouterDemo2")
public class ActivityToolRouterDemo2 extends AppCompatActivity {
    //用来获取ToolRouter跳转时，传递的数据
    @Extra
    long key1;
    @Extra
    String key2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toolrouter_demo2);
        init();
    }

    private void init() {
        //用来处理Extra注解
        ToolRouter.getInstance().inject(this);
        TextView show = findViewById(R.id.showInfo);
        show.setText("从demo1收到如下数据：\n" + toString());

        View.OnClickListener clickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v.getId() == R.id.jump_demo2_demo1) {
                    //应用内的简单跳转
                    ToolRouter.getInstance().build("/demo1/activityToolRouterDemo1").navigation();
                }
            }
        };
        findViewById(R.id.jump_demo2_demo1).setOnClickListener(clickListener);
    }

    @Override
    public String toString() {
        return "ActivityToolRouterDemo2{" +
                "key1='" + key1 + '\'' +
                ", key2=" + key2 +
                '}';
    }
}
